import os
from typing import TypedDict, Annotated, Sequence

from dotenv import load_dotenv
from langchain_community.tools import TavilySearchResults
from langchain_core.messages import BaseMessage
from langchain_deepseek import ChatDeepSeek
from langchain_ollama import ChatOllama
from langgraph.graph import add_messages
from langgraph.prebuilt import create_react_agent

from langchain_weather import get_weather
from tool_call import write_file

load_dotenv(override=True)
DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY")
# model = ChatDeepSeek(model="deepseek-chat")
model = ChatOllama(model="qwen3:latest", base_url="http://192.168.97.217:11434")

print(f'name:{get_weather.name},description:{get_weather.description},args:{get_weather.args}')
search = TavilySearchResults(max_results=2)
tools = [get_weather, write_file, search]
graph = create_react_agent(model=model, tools=tools)

class State(TypedDict):
    messages: Annotated[Sequence[BaseMessage], add_messages]
